const http = require('http')

http.createServer((request,response) =>{
  let body = []
  request.on('error', (err)=>{
    console.error(err);
  }).on('data', (chunk)=>{
    // console.log(chunk.toString());
    // body.push(chunk.toString());
    body.push(chunk);
  }).on('end', () =>{
    body = Buffer.concat(body).toString();
    // body = Buffer.concat([Buffer.from(body.toString())]).toString();
    console.log("body:",body)
    response.writeHead(200, {'Content-Type': 'text/html'});
    let html = `<html maaa="a">
  <head>
    <style>
     body div #myid{
      width: 100px;
      background-color: #ff500;
     }
     body div img{
       width: 30px;
       background-color: #ff1111;
     }
    </style>
  </head>
  <body>
    <p>hello ddd</p>
    <div>
      <img id="myid"  />
      <img  />
    </div>
  </body>
</html>`
    response.end(html);
  });
}).listen(8088);

console.log("server started");